import { BaseWindow } from "../../../component/window/BaseWindow";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { Cache } from "../../cache/Cache";
import { GuideTipsManager } from "../../manager/GuideTipsManager";
import { EffectManager } from "../../manager/EffectManager";
import { PopupManager } from "../../manager/PopupManager";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class BlessExpBottleDescPanel
    
    export  class BlessExpBottleDescPanel extends BaseWindow
    {
        constructor()
        {
            super();
            this.setSize(326, 240);
            this.titleHeight = 25;
            this.title = ObjCreate.createTitleTextField(Language.getString(69400));
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(18, 36, 290, 140, this);
            this._expBottleBg = new GImageBitmap("FriendsBless_ExpBottleBig.swf", 20, 25);
            this.addChild(this._expBottleBg);
            this._expBottleText = new Object /* flash.display.Bitmap */();
            this._expBottleText.x = 144;
            this._expBottleText.y = 48;
            this.addChild(this._expBottleText);
            LoaderManager.instance.load("FriendBlessText.png", this.onNameTextLoaded);
            this._expLabel = ObjCreate.createLabel(Language.getString(69401), 115, 75, 190, 20, flash.text.TextFormatAlign.LEFT, this, true);
            this._expLabel.setStyle("textFormat", new GTextFormat(FontUtil.songtiName, 14, null, true, null, null, null, null, flash.text.TextFormatAlign.LEFT));
            this._levelLabel = ObjCreate.createLabel(Language.getString(69402), 115, 95, 190, 20, flash.text.TextFormatAlign.LEFT, this, true, GlobalStyle.color7Uint);
            this._levelLabel.setStyle("textFormat", new GTextFormat(FontUtil.songtiName, 12, null, null, null, null, null, null, flash.text.TextFormatAlign.LEFT));
            var loc1=HTMLUtil.addColor(Language.getString(69403), GlobalStyle.color1) + "\n" + HTMLUtil.addColor(Language.getString(69404), "#00FF32");
            this._descText = ObjCreate.createTextField("", 115, 118, 190, 58, this, new GTextFormat(FontUtil.songtiName, 12, null, null, null, null, null, null, null, null, null, null, 3));
            this._descText.wordWrap = true;
            this._descText.htmlText = loc1;
            this._getExpBtn = ObjCreate.createGButton(Language.getString(69405), 60, 183, 75, 26, this, "ButtonSpecial");
            this._getExpBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._okeyFriendBtn = ObjCreate.createGButton(Language.getString(69427), 190, 183, 75, 26, this, "ButtonSpecial");
            this._okeyFriendBtn.toolTipData = HTMLUtil.addColor(Language.getString(69429), "#FFFFFF");
            this._okeyFriendBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOnekeyFriendButtonClick);
            this._hintLabel = ObjCreate.createLabel("", 170, 210, 115, 20, flash.text.TextFormatAlign.CENTER, this, false, 16776960);
            return;
        }

        /* internal  */onNameTextLoaded(arg1: ImageInfo): void
        {
            this._expBottleText.bitmapData = arg1.bitmapData;
            return;
        }

        /* internal  */onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.FriendBless_ExpBottleGetExp));
            this.hide();
            return;
        }

        /* internal  */onOnekeyFriendButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.OneKeyFriends_ShowWin));
            this.hide();
            return;
        }

        public updateExpInfo(): void
        {
            var loc1=Cache.instance.friendBless.bottleInfo;
            if (!loc1) 
            {
                return;
            }
            this._expLabel.htmlText = HTMLUtil.addColor(Language.getString(69401), GlobalStyle.color5) + HTMLUtil.addColor(loc1.exp + "", "#FFFF00") + HTMLUtil.addColor("/" + loc1.maxExp, GlobalStyle.color5);
            var loc2=Cache.instance.role.roleInfo.level >= loc1.needLevel;
            if (loc2) 
            {
                this._levelLabel.htmlText = HTMLUtil.addColor(Language.getString(69406), GlobalStyle.color1);
                this._getExpBtn.enabled = true;
            }
            else 
            {
                this._levelLabel.htmlText = HTMLUtil.addColor(Language.getStringByParam(69407, loc1.needLevel), GlobalStyle.color7);
                this._getExpBtn.enabled = false;
            }
            return;
        }

        public updateOnekeyStatus(): void
        {
            var loc2=null;
            var loc1=Cache.instance.friendBless.useOneKeyFriendInfo();
            if (loc1.remainTime != 0) 
            {
                if (loc1.isCanUse) 
                {
                    this._okeyFriendBtn.enabled = true;
                    this._hintLabel.htmlText = "";
                    loc2 = GuideTipsManager.getGuideTips2(GuideTipsManager.Dir_BL, Language.getString(69432));
                    loc2.x = this._okeyFriendBtn.x + this._okeyFriendBtn.width;
                    loc2.y = this._okeyFriendBtn.y;
                    this.addChild(loc2);
                    EffectManager.glowFilterReg(this._okeyFriendBtn, [new Object /* flash.filters.GlowFilter */(16776960)]);
                }
                else 
                {
                    this._okeyFriendBtn.enabled = false;
                    this._hintLabel.htmlText = HTMLUtil.addColor(Language.getStringByParam(69430, loc1.nextLevel, loc1.usedTime), "#FFFF00");
                }
            }
            else 
            {
                this._okeyFriendBtn.visible = false;
                this._hintLabel.visible = false;
                this._getExpBtn.x = 120;
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            this.updateOnekeyStatus();
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            PopupManager.removePopup(this);
            if (this._okeyFriendBtn) 
            {
                EffectManager.glowFilterUnReg(this._okeyFriendBtn);
            }
            if (GuideTipsManager.guideTips2.parent == this) 
            {
                GuideTipsManager.hideGuideTips2();
            }
            return;
        }

        /* internal */ /* var */_expBottleText: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_expLabel: GLabel;

        /* internal */ /* var */_levelLabel: GLabel;

        /* internal */ /* var */_descText: Object /* flash.text.TextField */;

        /* internal */ /* var */_expBottleBg: GImageBitmap;

        /* internal */ /* var */_getExpBtn: GButton;

        /* internal */ /* var */_okeyFriendBtn: GButton;

        /* internal */ /* var */_hintLabel: GLabel;
    }
